package com.demo15;

import java.io.File;
import java.io.IOException;

public class FileDemo1 {
    public static void main(String[] args) throws IOException {
        File f1 = new File("javaSE.txt");
        System.out.println(f1.isFile());
        System.out.println(f1.isDirectory());
        System.out.println(f1.exists());
        System.out.println(f1.delete());

        System.out.println("==================");
        File f2 = new File("idea_demo\\javaSE");
        System.out.println(f2.isDirectory());
        System.out.println(f2.mkdirs());
        System.out.println(f2.getAbsoluteFile());
        System.out.println(f2.getPath());
        System.out.println(f2.getName());

        File f3 = new File(f2,"JavaSE");
        File f4= new File(f2,"JavaCode");
        File f5 = new File(f2,"java.txt");
        System.out.println(f3.mkdir());
        System.out.println(f4.mkdir());
        System.out.println(f5.createNewFile());

        System.out.println("-----");
        //获取列表的信息操作
        String[] list = f2.list();

        for (String ls:list){
            System.out.println(f2.getName()+"/"+ls);
        }

        System.out.println("-------------------------");
        File[] files = f2.listFiles();

        for (File file: files){
            if(file.isDirectory()){
                System.out.println("📂:"+file.getName());
            }else{
                System.out.println("😚:"+file.getName());
                System.out.println(file.delete());
            }
        }
    }
}
